package org.tuestudent.grouppa;

import org.junit.Test;

import junit.framework.TestCase;


public class LoginTest extends TestCase {

    private Login instance;
    
    @Override
    public void setUp() {
        Main.initializeApp();
        instance = new Login();
    }
    
    public void testIsValid(String name, boolean exp) {
        assertEquals(instance.isValid(name), exp);
    }
    
    public void testEmail(String email, boolean exp) {
        assertEquals(instance.emailIsValid(email), exp);
    }
    
    //---------------------valid cases-------------------------
    @Test
    public void shortLower() {
        testIsValid("mic", true);
    }
    
    @Test
    public void shortUpper() {
        testIsValid("MIC", true);
    }
    
    @Test
    public void longLower() {
        testIsValid("iamawesomeandiknowit", true);
    }
    
    @Test
    public void longLowerSpaces() {
        testIsValid("i am awesome and i know it", true);
    }
    
    @Test
    public void longUpper() {
        testIsValid("IAMAWESOMEANDIKNOWIT", true);
    }
    
    @Test
    public void longUpperSpaces() {
        testIsValid("I AM AWESOME AND I KNOW IT", true);
    }
    
    @Test
    public void shortMix() {
        testIsValid("Iam", true);
    }
    
    @Test
    public void longMix() {
        testIsValid("IamaweSomeandIknOwIT", true);
    }
    
    @Test
    public void longMixSpaces() {
        testIsValid("I am aweSome and I knOw IT", true);
    }
    
    @Test
    public void shortLowerNumber() {
        testIsValid("mic123", true);
    }
    
    @Test
    public void shortUpperNumber() {
        testIsValid("MIC123", true);
    }
    
    @Test
    public void longLowerNumber() {
        testIsValid("iamawesomeandiknowit123456", true);
    }
    
    @Test
    public void longLowerSpacesNumber() {
        testIsValid("i am awesome and i know it 1 2 3 4 5 6", true);
    }
    
    @Test
    public void longUpperNumber() {
        testIsValid("IAMAWESOMEANDIKNOWIT123456", true);
    }
    
    @Test
    public void longUpperSpacesNumber() {
        testIsValid("I AM AWESOME AND I KNOW IT 1 2 3 4 5 6", true);
    }
    
    @Test
    public void shortMixNumber() {
        testIsValid("I4m", true);
    }
    
    @Test
    public void longMixNumber() {
        testIsValid("I4maw3S0me4ndIkn0wIT", true);
    }
    
    @Test
    public void longMixSpacesNumber() {
        testIsValid("I 4m aw3S0me and 1 knOw IT", true);
    }
    //----------------invalid cases---------------------
    
    @Test
    public void monkeytail() {
        testIsValid("mich@el", false);
    }
    
    @Test
    public void slash() {
        testIsValid("michae/", false);
    }
    
    @Test
    public void hashtag() {
        testIsValid("mic#ael", false);
    }
    
    @Test
    public void exclamation() {
        testIsValid("m!chael", false);
    }
    
    @Test
    public void percentage() {
        testIsValid("mi%hael", false);
    }
    
    @Test
    public void asterix() {
        testIsValid("micha*l", false);
    }
    
    @Test
    public void brackets() {
        testIsValid("michae)", false);
    }
    
    @Test
    public void brackets2() {
        testIsValid("michae(", false);
    }
    
    @Test
    public void and() {
        testIsValid("mich&el", false);
    }
    
    @Test
    public void empty() {
        testIsValid("", false);
    }
    
    //-----------------email test cases-----------------
    @Test
    public void normal() {
        testEmail("m.m.yeh@student.tue.nl", true);
    }
    
    @Test
    public void emailSymbols() {
        testEmail("Måçïjäê@student.tue.nl", true);
    }
    
    @Test
    public void noMonkeytail() {
        testEmail("m.m.yehstudent.tue.nl", false);
    }
    
    @Test
    public void noDots() {
        testEmail("mmyeh@studenttuenl", false);
    }
    
    @Test
    public void noEmailDomain() {
        testEmail("m.m.yeh@", false);
    }
    
    @Test
    public void noName() {
        testEmail("@student.tue.nl", false);
    }
    
    @Test
    public void emptyMail() {
        testEmail("", false);
    }
}
